import '../utils/httputils/urlpath.dart';
import '../utils/util.dart';

extension GetNavigationEx on GetInterface {
  ///find拓展，未注册时为空
  S? findOr<S>({String? tag}) {
    if (Get.isRegistered<S>(tag: tag)) {
      return Get.find<S>(tag: tag);
    }
    return null;
  }

  ///延迟返回
  void backDelay<T>({
    T? result,
    bool closeOverlays = false,
    bool canPop = true,
    int? id,
  }) async {
    await Future.delayed(const Duration(milliseconds: 800));
    back(
      result: result,
      closeOverlays: closeOverlays,
      canPop: canPop,
      id: id,
    );
  }

  //用户协议
  Future<T?>? toAgreeAssessment<T>() async {
    return await toNamed(RouterPath.web_view, parameters: {
      'url': UrlPath.agreeAssessment,
      'title': "用户协议",
      'safeArea': '1',
    });
  }

// 隐私政策
  Future<T?>? toAgreePrivacy<T>() async {
    return await toNamed(RouterPath.web_view, parameters: {
      'url': UrlPath.agreePrivacy,
      'title': "隐私政策",
      'safeArea': '1',
    });
  }
}
